package com.tsing.bms.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tsing.bms.service.IOrderService;
import com.tsing.bms.vo.req.AddOrderReqVo;
import com.tsing.bms.vo.req.IdAndStatusReqVo;
import com.tsing.bms.vo.req.IdReqVo;
import com.tsing.bms.vo.req.OrderPageReqVo;
import com.tsing.bms.vo.resp.OrderCountRespVo;
import com.tsing.bms.vo.resp.OrderPageRespVo;
import com.tsing.common.annotations.SystemLog;
import com.tsing.common.utils.ResultUtil;
import com.tsing.common.vo.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author TheTsing
 * @create 2022-05-03 15:30
 */
@Api(tags = "账单管理")
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @GetMapping("/orderPage")
    @ApiOperation(value = "账单分页")
    @SystemLog(description = "账单分页")
    public ResultData<Page<OrderPageRespVo>> orderPage(@Validated OrderPageReqVo reqVo) {
        return ResultUtil.success(orderService.orderPage(reqVo));
    }

    @PutMapping("/updateOrder")
    @ApiOperation(value = "修改账单")
    @SystemLog(description = "修改账单")
    public ResultData updateOrder(@Validated @RequestBody IdAndStatusReqVo reqVo) {
        orderService.updateOrder(reqVo);
        return ResultUtil.success();
    }

    @PostMapping("/addOrder")
    @ApiOperation(value = "新增账单")
    @SystemLog(description = "新增账单")
    public ResultData addOrder(@Validated @RequestBody AddOrderReqVo reqVo) {
        orderService.addOrder(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/orderCount")
    @ApiOperation(value = "账单统计")
    @SystemLog(description = "账单统计")
    public ResultData<OrderCountRespVo> orderCount(@Validated IdReqVo reqVo) {
        return ResultUtil.success(orderService.orderCount(reqVo));
    }


}